<?php
/* @var $this ChuongtrinhController */
/* @var $model Chuongtrinh */

$this->breadcrumbs=array(
	'Danh mục học phần'=>array('admin'),
	$model->hocki, $model->mamh
);

$this->menu=array(
	array('label'=>'Quản lý học phần', 'url'=>array('monhoc/admin')),
	array('label'=>'Quản lý danh mục học phần', 'url'=>array('admin')),
	array('label'=>'Quản lý thông tin sinh viên', 'url'=>array('thongtinsv/admin')),
	array('label'=>'Quản lý nhóm lớp', 'url'=>array('nhomlop/admin')),
	array('label'=>'Phát sinh nhóm lớp', 'url'=>array('qhmonhom/admin')),
);
?>

<h1>Học phần <?php $connection=Yii::app()->db;   // assuming you have configured a "db" connection
			$command=$connection->createCommand()
			->select('mamh,tenmh')
			->from('monhoc')
			//->where(array('and','username="'.$this->username.'"','level>0'))
			->query();
			foreach($command as $row)
			{
				if($model->mamh==$row['mamh'])
					echo $row['tenmh'];
			}
 ?></h1>

<?php
$this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
		'stt',
		'hocki',
		array(
			'header'=>'Học phần',
			'name'=>'mamh',
			'value'=>function($model){
				$connection=Yii::app()->db;   // assuming you have configured a "db" connection
			$command=$connection->createCommand()
			->select('mamh,tenmh')
			->from('monhoc')
			//->where(array('and','username="'.$this->username.'"','level>0'))
			->query();
			$hocphan= array();
			foreach($command as $row)
			{
				//array_push($ngach,$row);
				$hocphan[$row['mamh']]=$row['tenmh'];
			}
			foreach($hocphan as $ma=>$ten)
			{
				if($model->mamh==$ma)
				return $ten;
			}},	
		),
		array(
			'header'=>'Khoa phụ trách',
			'name'=>'madonvi',
			'value'=>function($model){
				$connection=Yii::app()->db;
				$commandDV=$connection->createCommand()
					->select('madonvi,tendonvi')
					->from('donvicongtac')
					->query();
					$khoa= array();
					foreach($commandDV as $rowDV)
					{
						//array_push($ngach,$row);
						if(substr( $rowDV['madonvi'],0,1)=='K')
						{
						$khoa[$rowDV['madonvi']]=$rowDV['tendonvi'];}
					}
			foreach($khoa as $ma=>$ten)
			{
				if($model->madonvi==$ma)
				return $ten;
			}},	
		),
		'nganh',
		'he',
		'ghichu',
	),
)); ?>
